local qizhou = fk.CreateSkill{
  name = "wk_heg__qizhou",
}

local HG = require "packages.new_heg_diy_my.util"

Fk:loadTranslationTable{
  ["wk_heg__qizhou"] = "绮胄",
  [":wk_heg__qizhou"] = "准备阶段，若你的<a href= ':Heg__policy'>“战策”</a>数小于你装备区内牌的花色数，你可将你的<a href= ':Heg__policy'>“战策”</a>数调整至你装备区内牌的花色数，否则你本回合摸牌数和使用【杀】次数上限+1。",
  ["@@wk_heg__qizhou-turn"] = "绮胄",

  ["$wk_heg__qizhou1"] = "人靠衣装马靠鞍！",
  ["$wk_heg__qizhou2"] = "这一身装备，叫你开开眼界！",
}

qizhou:addEffect(fk.EventPhaseStart, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(qizhou.name) and player == target and player.phase == Player.Start
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local suits = {}
    for _, e in ipairs(player:getCardIds("e")) do
      table.insertIfNeed(suits, Fk:getCardById(e).suit)
    end
    if #suits > HG.GetPolicyNum(player) then
      local num = #suits - HG.GetPolicyNum(player)
      HG.GetPolicy(room, player, num, self.name)
    else
      room:addPlayerMark(player, "@@wk_heg__qizhou-turn")
      room:addPlayerMark(player, MarkEnum.SlashResidue.."-turn")
    end
  end,
})

qizhou:addEffect(fk.DrawNCards, {
  is_delay_effect = true,
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    return player == target and player:getMark("@@wk_heg__qizhou-turn") > 0
  end,
  on_use = function (self, event, target, player, data)
    data.n = data.n + player:getMark("@@wk_heg__qizhou-turn")
  end,
})

return qizhou